import { ADD_COUNTER, ADD_TO_CART } from "@/store/mutations-types";

export default {
  addCart({state, commit}, payload) {
    const oldProduct = state.cartList.find(item => item.iid === payload.iid)
    if(oldProduct) {
      commit(ADD_COUNTER, oldProduct)
      // oldProduct.count += 1
    }
    payload.count = 1
    commit(ADD_TO_CART, payload)
    // state.cartList.push(payload)
  }
}
